#include <bits/stdc++.h>
#define int long long
using namespace std;

const int maxn = 1e3+ 5;
int arr[maxn][maxn]; // 使用一维数组代表二维数组
int diff[maxn][maxn];


void solve(){
	int n, m, q;
	cin >> n >> m >> q;
	for (int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++){
			cin >> arr[i][j];
		}
	}
	
	// 做差分, 得到二维差分数组
	for (int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++){
			diff[i][j] = arr[i][j] - arr[i-1][j] - arr[i][j-1] + arr[i-1][j-1];
		}
	}
	
	// 处理差分数组
	int x1, y1, x2, y2, c;
	for (int i=1;i<=q;i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> c;
		diff[x1][y1] += c;
		diff[x1][y2+1] -= c;
		diff[x2+1][y1] -= c;
		diff[x2+1][y2+1] += c;
	}
	
	// 对差分数组做前缀和, 就能得出最后的结果
	for (int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++){
			diff[i][j] = diff[i][j] + diff[i-1][j] + diff[i][j-1] - diff[i-1][j-1];
		}
	}
	
	// 输出最后结果
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cout << diff[i][j] << ' ';
		}
		cout << '\n';
	} 
}



signed main(){
	int t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}
